package intention;

import cn.hutool.core.util.RandomUtil;
import com.bigmodel.entity.QAEntity;
import com.bigmodel.util.ExcelUtil;
import com.bigmodel.util.FtlUtil;
import org.junit.Test;

import java.util.*;

public class IntentionSFT_All {

    private final static String OUT_PATH = "D:\\javacode\\bigmodel\\bigmodel\\qa_intention\\";
    private final static String FREEMARKER_BASE_PATH = "intention/";
    private static List<String> systemNameList = new ArrayList<>();
    private static List<String> objectList = new ArrayList<>();

    private static List<String> faultList = new ArrayList<>();

    private static String[] metricAttr = {
            "app.user.active.count",
            "app.tps",
            "app.session.active.count",
            "app.response-time.avg",
            "app.request.active.total.count",
            "host.cpu.use.rate",
            "host.memory.use.rate",
            "host.disk.use.rate",
            "host.disk.io.use.rate",
            "内存利用率",
            "CPU利用率",
            "磁盘IO利用率",
            "平均处理时间",
            "活跃用户会话数",
            "并发用户数",
            "每秒处理量",
            "活跃会话数",
            "平均响应时间",
            "活动请求数",
            "cpu使用率",
            "内存使用率",
            "磁盘总利用率"
    };


    static {
        systemNameList.addAll(Arrays.asList(FaultTitleConstants.BUSINESS_SYSTEM_LIST));

        objectList.addAll(Arrays.asList(FaultTitleConstants.DB_LIST));
        objectList.addAll(Arrays.asList(FaultTitleConstants.APPLICATION_LIST));
        objectList.addAll(Arrays.asList(FaultTitleConstants.HOST_LIST));
        objectList.addAll(Arrays.asList(FaultTitleConstants.POD_LIST));
        objectList.addAll(Arrays.asList(FaultTitleConstants.CONTAINER_LIST));
        objectList.addAll(Arrays.asList(FaultTitleConstants.VM_LIST));
        objectList.addAll(Arrays.asList(FaultTitleConstants.APPLICATION_INSTANCE_LIST));

        faultList.addAll(Arrays.asList(FaultTitleConstants.FAULT_TITLE_LIST));
    }


    public static void main(String[] args) {
        T001();//健康度查询
        T002();//监控数据查询
        T003();//指标异常检测
        T004();//指标预测
        T005();//资产查询
        T006();//资产关系查询
        T007();//故障查询意图
        T008();//故障解决方案查询意图

    }


    private static void T001() {
        String code = "T001";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${systemName}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String systemName : systemNameList) {
                for (String action : IntentionAction.T001_action) {
                    if (action.contains("${systemName}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${systemName}",systemName);
                        map.put("question", question);
                        map.put("systemName", systemName);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String action : IntentionAction.T001_action) {
                    if (!action.contains("${systemName}") && action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${time}",time);
                        map.put("question", question);
                        map.put("time", time);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${systemName}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String systemName : systemNameList) {
                for (String action : IntentionAction.T001_action) {
                    if (action.contains("${time}") && action.contains("${systemName}")) {
                        for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${time}",time).replace("${systemName}",systemName);
                            map.put("question", question);
                            map.put("time", time);
                            map.put("systemName", systemName);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }

    private static void T002() {
        String code = "T002";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${name}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String action : IntentionAction.T002_action) {
                    if (action.contains("${name}") && !action.contains("${metric}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${metric}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String metric : metricAttr) {
                for (String action : IntentionAction.T002_action) {
                    if (!action.contains("${name}") && action.contains("${metric}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${metric}",metric);
                        map.put("question", question);
                        map.put("metric", metric);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String action : IntentionAction.T002_action) {
                    if (!action.contains("${name}") && !action.contains("${metric}") && action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${time}",time);
                        map.put("question", question);
                        map.put("time", time);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${metric}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String metric : metricAttr) {
                    for (String action : IntentionAction.T002_action) {
                        if (action.contains("${name}") && action.contains("${metric}") && !action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${metric}",metric);
                            map.put("question", question);
                            map.put("metric", metric);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/4/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/4/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }

                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                    for (String action : IntentionAction.T002_action) {
                        if (action.contains("${name}") && !action.contains("${metric}") && action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${time}",time);
                            map.put("question", question);
                            map.put("time", time);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/5/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/5/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }

                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${metric}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String metric : metricAttr) {
                    for (String action : IntentionAction.T002_action) {
                        if (!action.contains("${name}") && action.contains("${metric}") && action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question =  action.replace("${metric}",metric).replace("${time}",time);
                            map.put("question", question);
                            map.put("time", time);
                            map.put("metric", metric);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/6/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/6/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${metric}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                /*if(RandomUtil.randomInt(0,1)==0){
                    continue;
                }*/
                for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                    /*if(RandomUtil.randomInt(0,1)==0){
                        continue;
                    }*/
                    for (String metric : metricAttr) {
                        for (String action : IntentionAction.T002_action) {
                            if (action.contains("${name}") && action.contains("${metric}") && action.contains("${time}")) {
                                Map<String, Object> map = new HashMap<>();
                                String question = action.replace("${name}",name).replace("${metric}",metric).replace("${time}",time);
                                map.put("question", question);
                                map.put("time", time);
                                map.put("name", name);
                                map.put("metric", metric);
                                String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/7/prompt.ftl");
                                String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/7/answer.ftl");
                                qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                            }
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }

    private static void T003() {
        String code = "T003";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${name}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String action : IntentionAction.T003_action) {
                    if (action.contains("${name}") && !action.contains("${metric}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${metric}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String metric : metricAttr) {
                for (String action : IntentionAction.T003_action) {
                    if (!action.contains("${name}") && action.contains("${metric}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${metric}",metric);
                        map.put("question", question);
                        map.put("metric", metric);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String action : IntentionAction.T003_action) {
                    if (!action.contains("${name}") && !action.contains("${metric}") && action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${time}",time);
                        map.put("question", question);
                        map.put("time", time);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${metric}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String metric : metricAttr) {
                    for (String action : IntentionAction.T003_action) {
                        if (action.contains("${name}") && action.contains("${metric}") && !action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${metric}",metric);
                            map.put("question", question);
                            map.put("metric", metric);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/4/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/4/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }

                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                    for (String action : IntentionAction.T003_action) {
                        if (action.contains("${name}") && !action.contains("${metric}") && action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${time}",time);
                            map.put("question", question);
                            map.put("time", time);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/5/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/5/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }

                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${metric}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String metric : metricAttr) {
                    for (String action : IntentionAction.T003_action) {
                        if (!action.contains("${name}") && action.contains("${metric}") && action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question =  action.replace("${metric}",metric).replace("${time}",time);
                            map.put("question", question);
                            map.put("time", time);
                            map.put("metric", metric);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/6/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/6/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${metric}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                /*if(RandomUtil.randomInt(0,1)==0){
                    continue;
                }*/
                for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                    /*if(RandomUtil.randomInt(0,1)==0){
                        continue;
                    }*/
                    for (String metric : metricAttr) {
                        for (String action : IntentionAction.T003_action) {
                            if (action.contains("${name}") && action.contains("${metric}") && action.contains("${time}")) {
                                Map<String, Object> map = new HashMap<>();
                                String question = action.replace("${name}",name).replace("${metric}",metric).replace("${time}",time);
                                map.put("question", question);
                                map.put("time", time);
                                map.put("name", name);
                                map.put("metric", metric);
                                String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/7/prompt.ftl");
                                String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/7/answer.ftl");
                                qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                            }
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }


    private static void T004() {
        String code = "T004";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${name}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String action : IntentionAction.T004_action) {
                    if (action.contains("${name}") && !action.contains("${metric}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${metric}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String metric : metricAttr) {
                for (String action : IntentionAction.T004_action) {
                    if (!action.contains("${name}") && action.contains("${metric}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${metric}",metric);
                        map.put("question", question);
                        map.put("metric", metric);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${metric}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String metric : metricAttr) {
                    for (String action : IntentionAction.T004_action) {
                        if (action.contains("${name}") && action.contains("${metric}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${metric}",metric);
                            map.put("question", question);
                            map.put("metric", metric);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }

    private static void T005() {
        String code = "T005";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${name}
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String action : IntentionAction.T005_action) {
                    if (action.contains("${name}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        {//null
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String action : IntentionAction.T005_action) {
                    if (!action.contains("${name}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action;
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }


        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }

    private static void T006() {
        String code = "T006";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String name : objectList) {
                for (String action : IntentionAction.T006_action) {
                    if (action.contains("${name}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }

            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        {//null
            List<QAEntity> qaEntityList = new ArrayList<>();
            for (String name : objectList) {
                for (String action : IntentionAction.T006_action) {
                    if (!action.contains("${name}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action;
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }


        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }

    private static void T007() {
        String code = "T007";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${name}
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String name : faultList) {
                for (String action : IntentionAction.T007_action) {
                    if (action.contains("${name}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${time}
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String action : IntentionAction.T007_action) {
                    if (!action.contains("${name}") && action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question =  action.replace("${time}",time);
                        map.put("question", question);
                        map.put("time", time);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String name : faultList) {
                for (String action : IntentionAction.T007_action) {
                    for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                        if (action.contains("${name}") && action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${time}",time);
                            map.put("question", question);
                            map.put("time", time);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }


        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }

    private static void T008() {
        String code = "T008";
        String category = "";

        List<QAEntity> allList = new ArrayList<>();
        {//${name}
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String name : faultList) {
                for (String action : IntentionAction.T008_action) {
                    if (action.contains("${name}") && !action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${name}",name);
                        map.put("question", question);
                        map.put("name", name);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/1/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${time}
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                for (String action : IntentionAction.T008_action) {
                    if (!action.contains("${name}") && action.contains("${time}")) {
                        Map<String, Object> map = new HashMap<>();
                        String question = action.replace("${time}",time);
                        map.put("question", question);
                        map.put("time", time);
                        String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/prompt.ftl");
                        String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/2/answer.ftl");
                        qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }
        {//${name}${time}
            List<QAEntity> qaEntityList = new ArrayList<>();

            for (String name : faultList) {
                for (String action : IntentionAction.T008_action) {
                    for (String time : IntentionTime.TIMEARRAY_ALL_OF_DENGDONG) {
                        if (action.contains("${name}") && action.contains("${time}")) {
                            Map<String, Object> map = new HashMap<>();
                            String question = action.replace("${name}",name).replace("${time}",time);

                            map.put("question", question);
                            map.put("time", time);
                            map.put("name", name);
                            String questionContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/prompt.ftl");
                            String answerContent = FtlUtil.generateContent(map, FREEMARKER_BASE_PATH + code + "/3/answer.ftl");
                            qaEntityList.add(new QAEntity(code, category, questionContent, answerContent));
                        }
                    }
                }
            }
            if (qaEntityList.size() > 500) {
                qaEntityList = random50List(qaEntityList);
            }
            allList.addAll(qaEntityList);
        }

        ExcelUtil.createExcel(allList, OUT_PATH + code + ".xls");
    }


    @Test
    public void test2() {
        for (int i = 0; i < 100; i++) {
            System.out.println(RandomUtil.randomLong(1, 4));
        }
    }

    public static List<QAEntity> random50List(List<QAEntity> allList) {
/*        List<QAEntity> newList = new ArrayList<>();
        for (int i = 0; i < 500; i++) {
            newList.add(allList.get(RandomUtil.randomInt(0, allList.size())));
        }
        return newList;*/
        return allList;
    }


}
